#include "WorkflowManager.h"

WorkflowManager *WorkflowManager::_manager = nullptr;

WorkflowManager::WorkflowManager()
{
}

WorkflowManager::~WorkflowManager()
{
}

void WorkflowManager::Initialize()
{
    if(_manager != nullptr)
    {
        return;
    }

    _manager = new WorkflowManager;
    _manager->_controlThread.reset(new QThread);
    _manager->_controlThread->setObjectName("Workflow Manager");
    _manager->moveToThread(_manager->_controlThread.get());
    connect(_manager->_controlThread.get(), SIGNAL(started()), _manager, SLOT(OnStart()));
    _manager->_controlThread->start();
}

void WorkflowManager::Deinitialize()
{
}

void WorkflowManager::OnStarted()
{
    ProcessCommands();
}

void WorkflowManager::ProcessCommands()
{
    while(!_commands.empty())
    {
        ICommand command = _commands.front();
        _commands.pop_front();
    }
}
